#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
using namespace std;
const int N = 100000;

int dpmax(int* p, int n)
{
    int maxmon = 0;
    for (int i = 1; i < n; i++)
    {
        maxmon = max(maxmon, (p[n] - p[i]));
    }

    return maxmon;
}

int main() {
    int n  = 7;
    int p[8] = { 0,8,9,2,5,4,7,1 };
    /*for (int i = 1; i < n + 1; i++)
    {
        cin >> p[i];
    }*/

    int maxnum = 0;
    for (int i = 1; i < n + 1; i++)
    {
        maxnum = max(maxnum, dpmax(p, i));
    }

    cout << maxnum << endl;


}